package compiler.terminals;

import compiler.HowlToken;
import compiler.HowlType;
import compiler.TokenReader;
import compiler.exceptions.HowlParserException;

/**
 * Class to represent the name an value of a datum, as used by insert
 * statements.
 * 
 * @author Sarah Mount <s.mount@wlv.ac.uk>
 * @version 16 Dec 2009
 * 
 * @see compiler.nonterminals.InsertStmt
 * @see compiler.terminals.Number
 */
public class DataValue extends HowlToken {

	private String name;
	private Number value;

	public DataValue(TokenReader tokenReader) {
		super(tokenReader);
	}

	@Override
	public String codeGenerate() {
		return this.toString();
	}

	@Override
	public HowlToken parse() throws HowlParserException {
		this.name = this.tokenReader.consumeToken();
		this.value = (Number) new Number(this.tokenReader).parse();
		return this;
	}

	@Override
	public String toString() {
		return this.name + " " + this.value.toString();
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the value
	 */
	public Number getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(Number value) {
		this.value = value;
	}


}
